<!--************************************************************************************************-->
<!-- < myPage.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Founder & Modifier: Xiaoxin Mo                                                                 -->
<!-- Stu : 10389159                                                                                 -->
<!-- Date: 2012-12-23                                                                               -->
<!-- Destription :                                                          -->
<!--                                                                                                -->
<!-- Version : 2.1                                                                                  -->
<!--************************************************************************************************-->


<!DOCTYPE html>
<?php
	//session_start();
	include_once("header.php");  // header里面已经调用session_start()
	//include_once("bottom.php");
	include_once("../manager/BookManager.php");
	include_once("../manager/ThesisManager.php");
	include_once("../manager/GroupManager.php");
	include_once("../manager/NoteManager.php");
	include_once("../manager/CommentManager.php");
	include_once("../manager/FriendManager.php");
	include_once("../manager/UserManager.php");
	
	$currentUser = $_SESSION['currentUser'];
	$currentID = $_SESSION['currentID'];
	// parameter $N to be modified
	$friendnames = FriendManager::getInstance()->getFriendnameByUsername($currentUser, 10);
?>
<html lang="zh-hk">
<head>

	<title>Tiny bOOk</title>
	
	<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
	<meta name="contentType" value="text/html  charset=GBK">
	<meta name="description" content="在这里你可以看到最新发布的书籍，和好友共享对某本书的评论和笔记">
	<meta http-equiv="imagetoolbar" content="no">
	<meta name="viewport" content="width=1036">
	
	<link rel="stylesheet" type="text/css" href="../css/myPage.css">
</head>

<body>
	<div id="main">
		<div id="right">	
			<div id="apply">
				<p><a href="addGroup.php"><span>申请创建小组</span></a></p>
				<p><a href="upload_book.php"><span>申请上传书籍</span></a></p>
				<p><a href="addThesis.php"><span>申请上传论文</span></a></p>
			</div>
			<!--modified by xiaojing,10389144,1/2/2012-->
			<div id="myfriends">			
				<!--默认个人主页上只显示5个好友-->
				<div id="friends">
					<p>我的好友：</p>			
					<?php
						foreach($friendnames as $friend)
						{
					?>
							<p><a href="userPage.php?user_name=<?=$friend?>"><?=$friend?></a></p>
					<?php
						}
					?>
				</div>
				<p>添加好友：</p>
				
											
				<form action="addFriendResult.php" method="post">
					<span><input type="text" name="username" size="10"/></span>
					<input class="addfriend" type="submit" name="addfriend" value="添加好友"/>
				</form>
			</div>
		</div>
		
		<div id="left">
			<div id="personal">
				<h2>我的个人主页</h2>
			</div>
			<div id="info">
				<div id="basic_info">
					<p>用户名：<?=$currentUser?></p>
				</div>
				<div id="uploadbooks" class="info_detail">
					<p>我上传的书籍：</p>
					<div class="content">
						<?php
						// get 4 books for the list
						$bookList = BookManager::getInstance()->getBooklistByUserID($currentID, 4);
						
						foreach ($bookList as $bookname)
						{
							// record the bookname so can get the value when clicking it 
							$_SESSION['currentBook'] = $bookname;
						?>
							<p><a href="bookPage.php?book_name=<?=$bookname?>"><?=$bookname?></a></p>
						<?php
						}
						?>
					</div>
				</div>
				<div id="uploadpapers" class="info_detail">
					<p>我上传的论文：</p>
					<div class="content">
						<?php
						// get 4 theses for the list====================modified by xiaoxin
						$thesisList = ThesisManager::getInstance()->getThesisNamesByUserID($currentID, 4);
						
						foreach ($thesisList as $thesisname)
						{
							// record the bookname so can get the value when clicking it 
							$_SESSION['currentThesis'] = $thesisname;
						?>
							<p><a href="thesisPage.php?thesis_name=<?=$thesisname?>"><?=$thesisname?></a></p>
						<?php
						}
						?>
					</div>
				</div>
				<!--=========================modified by xiaoxin-->
				<div id="creategroups" class="info_detail">
					<p>我的小组：</p>
					<div class="content">
						<?php
						// get 4 books for the list
						$groupNames = UserManager::getInstance()->getGrouplistByUsername($currentUser);
						
						foreach ($groupNames as $groupName)
						{
						?>
							<p><a href="groupPage.php?group_name=<?=$groupName?>"><?=$groupName?></a></p>
						<?php
						}
						?>
					</div>
				</div>
				<!-- =======================by xiaoxin================== -->
				<div id="comments" class="info_detail">
					<p>我的评论：</p>
					<div class="content">
						<?php
						// get 4 books for the list
						$comments = CommentManager::getInstance()->getCommentlistByUsername($currentUser, 4);
						
						foreach ($comments as $comment)
						{
						?>
							<p><a href=""><?=$comment?></a></p>
						<?php
						}
						?>
					</div>
				</div>
				<!-- =======================by xiaoxin================== -->
				<div id="notes"  class="info_detail">
					<p><?=$currentUser?>的笔记：</p>
					<div class="content">
						<?php
						// get 4 books for the list
						$notes = NoteManager::getInstance()->getNotelistByUsername($currentUser, 4);

						foreach ($notes as $note)
						{
						?>
							<p><a href=""><?=$note?></a></p>
						<?php
						}
						?>
					</div>		
				</div>
			</div>
			
			
		</div>


		<!--<div id="bottom">
				<p>@2012 - 2014 by cat-fish,all rights reserves</p>
		</div>-->
	</div><!--end of main-->
</body>